/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Prototype;

import Model.Gates.AndGate;
import Model.Gates.OrGate;
import Model.Main.*;
import java.util.Scanner;
import sun.swing.PrintColorUIResource;

/**
 *
 * @author Pales
 */
enum command {

    HELP, ADDOSCILL, ADDGATE, ADDCHILDWIRE, ADDGATETOCOMP, ADDINVERTERTOCOMP, ADDLED, ADDINVERTER, ADDRATEGEN, ADDWIREGG, ADDWIREIG, COMPADDWIREIG, COMPADDWIREGG, COMPADDWIREGO, ADDBUTTON, ADDCOMPOSIT, SETBUTTON, DELETEWIRE, DELETE, CLEAN, RUN, STOP, PAUSE, EXIT, BAD, LOADFILE, GETVALUE, STEP
}

public class ConInt {

    Boolean consoleIsActive;
    String[] words;
    ProtoController proto;

    public ConInt(ProtoController proto) {
        consoleIsActive = true;
        this.proto = proto;
    }

    public void interpreter() {
        while (consoleIsActive) {
            System.out.println("");
            String selS = "";
            String[] words = {"bad"};
            command com = command.BAD;
            System.out.print(":");
            Scanner in = new Scanner(System.in);

            selS = in.nextLine();

            try {
                words = selS.split(" ");
            } catch (Exception e) {
                System.out.println("Bad Command!");
            }

            if (words.length != 0) {
                if (words[0].equals("addLed")) {
                    com = command.ADDLED;
                }
                if (words[0].equals("addGate")) {
                    com = command.ADDGATE;
                }
                if (words[0].equals("help")) {
                    com = command.HELP;
                }
                if (words[0].equals("addOscill")) {
                    com = command.ADDOSCILL;
                }
                if (words[0].equals("addGateToComp")) {
                    com = command.ADDGATETOCOMP;
                }
                if (words[0].equals("addInverterToComp")) {
                    com = command.ADDINVERTERTOCOMP;
                }
                if (words[0].equals("addButton")) {
                    com = command.ADDBUTTON;
                }
                if (words[0].equals("addComposite")) {
                    com = command.ADDCOMPOSIT;
                }
                if (words[0].equals("addInverter")) {
                    com = command.ADDINVERTER;
                }
                if (words[0].equals("addRategen")) {
                    com = command.ADDRATEGEN;
                }
                if (words[0].equals("addWireGG")) {
                    com = command.ADDWIREGG;
                }
                if (words[0].equals("addChildWire")) {
                    com = command.ADDCHILDWIRE;
                }
                if (words[0].equals("addWireIG")) {
                    com = command.ADDWIREIG;
                }
                if (words[0].equals("compAddWireIG")) {
                    com = command.COMPADDWIREIG;
                }
                if (words[0].equals("compAddWireGG")) {
                    com = command.COMPADDWIREGG;
                }
                if (words[0].equals("compAddWireGO")) {
                    com = command.COMPADDWIREGO;
                }
                if (words[0].equals("loadFile")) {
                    com = command.LOADFILE;
                }
                if (words[0].equals("clean")) {
                    com = command.CLEAN;
                }
                if (words[0].equals("delWire")) {
                    com = command.DELETEWIRE;
                }
                if (words[0].equals("delete")) {
                    com = command.DELETE;
                }
                if (words[0].equals("pause")) {
                    com = command.PAUSE;
                }
                if (words[0].equals("run")) {
                    com = command.RUN;
                }
                if (words[0].equals("setButton")) {
                    com = command.SETBUTTON;
                }
                if (words[0].equals("stop")) {
                    com = command.STOP;
                }
                if (words[0].equals("getValue")) {
                    com = command.GETVALUE;
                }
                if (words[0].equals("step")) {
                    com = command.STEP;
                }
                if (words[0].equals("exit")) {
                    com = command.EXIT;
                }
            }
            switch (com) {
                case HELP:
                    InterCommands.help();
                    break;
                case ADDOSCILL:
                    InterCommands.addOscill(proto, words);
                    break;
                case ADDLED:
                    InterCommands.addLed(proto, words);
                    break;
                case ADDBUTTON:
                    InterCommands.addButton(proto, words);
                    break;
                case ADDCOMPOSIT:
                    InterCommands.addComposite(proto, words);
                    break;
                case ADDINVERTER:
                    InterCommands.addInverter(proto, words);
                    break;
                case ADDGATE:
                    InterCommands.addGate(proto, words);
                    break;
                case ADDGATETOCOMP:
                    InterCommands.addGateToComp(proto, words);
                    break;
                case ADDINVERTERTOCOMP:
                    InterCommands.addInverterToComp(proto, words);
                    break;
                case ADDRATEGEN:
                    InterCommands.addRategen(proto, words);
                    break;
                case ADDWIREGG:
                    InterCommands.addWireGG(words, proto);
                    break;
                case ADDWIREIG:
                    InterCommands.addWireIG(words, proto);
                    break;
                case ADDCHILDWIRE:
                    InterCommands.addChildWire(words, proto);
                    break;
                case COMPADDWIREIG:
                    InterCommands.compAddWireIG(words, proto);
                    break;
                case COMPADDWIREGG:
                    InterCommands.compAddWireGG(words, proto);
                    break;
                case COMPADDWIREGO:
                    InterCommands.compAddWireGO(words, proto);
                    break;
                case STOP:
                    InterCommands.stop(proto, words);
                    break;
                case LOADFILE:
                    InterCommands.loadFile(proto, words);
                    break;
                case EXIT:
                    consoleIsActive = false;
                    break;

                case CLEAN:
                    InterCommands.clean(proto, words);
                    break;
                case DELETE:
                    InterCommands.delete(words, proto);
                    break;

                case DELETEWIRE:
                    InterCommands.delWire(words, proto);
                    break;
                case PAUSE:
                    InterCommands.pause(proto, words);
                    break;
                case RUN:
                    InterCommands.run(proto, words);
                    break;
                case SETBUTTON:
                    InterCommands.setbutton(words, proto);
                    break;
                case GETVALUE:
                    InterCommands.getValue(words, proto);
                    break;
                case STEP:
                    InterCommands.step(words, proto);
                    break;
                default:
                    System.out.println("unknown command");
                    break;
            }
        }
    }
}
